#!/usr/bin/env python

import nxt.locator
from nxt.motor import *

#'speed, limit and motor number (port) are all set by the calling C program
#'This .py will *not* work on its own!
def motor_move(b):
    motorport = 0
    if port == 0:
        motorport = PORT_A
    elif port == 1:
        motorport = PORT_B
    elif port == 2:
        motorport = PORT_C
    else:
        print 'Failed to set motor port'
    m_left = Motor(b, motorport)
    m_left.power = power
    m_left.mode = MODE_MOTOR_ON
    m_left.run_state = RUN_STATE_RUNNING
    m_left.tacho_limit = tacho
    m_left.set_output_state()

sock = nxt.locator.find_one_brick()
if sock:
    motor_move(sock.connect())
    sock.close()
else:
    print 'No NXT bricks found'
